home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Format CD 42
/
Amiga Format AFCD42 (Issue 126, Aug 1999).iso
/
-serious-
/
emulation
/
amigavgb_ppc
/
demos
/
test.c
< prev
next >
Wrap
C/C++ Source or Header
|
1999-05-17
|
23KB
|
402 lines
#include <stdlib.h>
#include <stdio.h>
#include <graphics.h>
void main()
{
char s[16];
int i, j, k;
mode(M_TEXT);
puts("A:text demo");
puts("B:graphic demo");
i = waitpad(J_A | J_B);
waitpadup();
if(i == J_A) {
strcpy(s, "Hello World!");
puts(s);
reverse(s);
puts(s);
for(i = 0; i <= 0x10; i++) {
printn(i, 16);
putchar(' ');
}
putchar(EOL);
for(i = 0; i < 3; i++) {
switch(i)
{
case 0:
printn(0, 10);
break;
case 1:
printn(1, 10);
break;
case 2:
printn(2, 10);
break;
default:
print("Error");
break;
}
putchar(' ');
}
putchar(EOL);
itoa(abs(-234), s);
puts(s);
itoa(atoi(s), s);
puts(s);
strcpy(s, "Hello");
strcat(s, " World!");
puts(s);
printn(strlen(s), 10);
putchar(EOL);
printn(strcmp(s, "Hello Earth!"), 10);
putchar(' ');
printn(strcmp(s, "Hello World!"), 10);
putchar(' ');
printn(strcmp(s, "Hi World!"), 10);
putchar(EOL);
print("Enter nb: ");
puts(gets(s));
print("2 * ");
print(s);
print(" = ");
puts(itoa(atoi(s) * 2, s));
print("Push START");
waitpad(J_START);
waitpadup();
} else {
mode(M_DRAWING);
/*
* Basic drawing on screen
*/
i = 50;
j = 50;
k = 0;
while(1) {
k = waitpad(J_UP | J_DOWN | J_LEFT | J_RIGHT | J_START);
if(k & J_START) {
break;
}
if(k & J_UP)
j--;
if(k & J_DOWN)
j++;
if(k & J_LEFT)
i--;
if(k & J_RIGHT)
i++;
if(i >= 0 && i <= 0x7F && j >= 0 && j <= 0x77)
plot(i, j, BLACK, XOR);
i = i < 0 ? 0 : i;
j = j < 0 ? 0 : j;
i = i > 0x7F ? 0x7F : i;
j = j > 0x77 ? 0x77 : j;
delay(100);
}
drawimage();
waitpad(J_START);
waitpadup();
}
}
void drawimage()
{
/* A fish generated with POV and dithered to 4 colors */
#asm
.globl .draw_image
LD BC,#img_data
CALL .draw_image
JP end_img_data
img_data:
; Image size: 0x80 x 0x78
; Line 0x00
.byte 0xFF,0xFF,0xAA,0xFF,0xDB,0xFF,0xAD,0xFF,0xDB,0xFF,0xB6,0xFF,0xDB,0xFF,0xAD,0xFF
.byte 0xFF,0xFF,0xAA,0xFF,0xDF,0xFF,0x75,0xFF,0xAE,0xFF,0xF5,0xFF,0x5F,0xFF,0xB5,0xFF
.byte 0xFF,0xFF,0xAA,0xFF,0xDF,0xFF,0x75,0xFF,0xAE,0xFF,0xF5,0xFF,0x5B,0xFF,0xAD,0xFF
.byte 0xFF,0xFF,0xAA,0xFF,0x76,0xFF,0xAB,0xFF,0xDA,0xFF,0x6D,0xFF,0x55,0xFF,0xAA,0xFF
.byte 0xFF,0xFF,0xAA,0xFF,0xDD,0xFF,0x6B,0xFF,0xB6,0xFF,0xAB,0xFF,0x6D,0xFF,0xB5,0xFF
.byte 0xFF,0xFF,0xAA,0xFF,0xDD,0xFF,0x6B,0xFF,0xB5,0xFF,0xDE,0xFF,0x52,0xFF,0x6D,0xFF
.byte 0xFD,0xFF,0xA5,0xFF,0xB6,0xFF,0x5A,0xFF,0xAB,0xFF,0xB5,0xFF,0xD5,0xFF,0x5A,0xDF
.byte 0xED,0xFF,0x35,0xFF,0xD5,0xFF,0xAB,0xFF,0x6D,0xFF,0x55,0xFF,0xAA,0xFF,0xB5,0xFF
.byte 0xB6,0xFF,0x55,0xFF,0x55,0xFF,0x55,0xFF,0x6A,0xFF,0x55,0xFF,0x55,0xFF,0xD5,0x7F
.byte 0xDB,0xFF,0x24,0xFF,0x55,0xFF,0x55,0xFF,0xAA,0xFF,0x55,0xFF,0x54,0xFF,0x55,0xFF
.byte 0x55,0xFF,0xAA,0xFF,0x51,0xFF,0x4A,0xFF,0xA8,0xFF,0x25,0xFF,0x90,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E,0x52,0xFC,0xA8,0xFC,0x52,0xFC,0xA5,0xF0
.byte 0x55,0x7F,0x55,0x7F,0x2A,0x7F,0x55,0x7F,0x49,0x7F,0x2A,0x3E,0xA4,0x3D,0x02,0x02
.byte 0x52,0xFF,0x4A,0xFF,0x28,0x7F,0x52,0xFB,0x28,0xFB,0x92,0xFF,0x44,0x77,0x52,0x77
.byte 0x21,0xFF,0x94,0xFF,0x42,0xFF,0x94,0xFF,0x40,0xFF,0x92,0xFF,0x00,0xFF,0xA8,0xFF
.byte 0x14,0xFF,0x41,0xFF,0x10,0xFF,0x85,0xFF,0x20,0xFF,0x04,0xFF,0x80,0xFF,0x08,0xFF
.byte 0x10,0xFF,0x0A,0xFF,0x41,0xFF,0x10,0xFF,0x04,0xFF,0x90,0xFF,0x00,0xFF,0x02,0xFF
.byte 0x44,0xFF,0x26,0xFF,0x16,0xFF,0x85,0xFF,0x24,0xFF,0x84,0xFF,0x0D,0xFF,0x0E,0xFF
.byte 0x49,0xFF,0x00,0x7F,0x24,0xFF,0x80,0x7F,0x20,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF
.byte 0x28,0xFF,0x01,0xFF,0x84,0xFF,0x10,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF
; Line 0x10
.byte 0xAA,0xFF,0xAA,0xFF,0xAA,0xFF,0xAA,0xFF,0x55,0xFF,0xAA,0xFF,0x95,0xFF,0x52,0xFF
.byte 0xAA,0xFF,0xAA,0xFF,0xAA,0xFF,0xAA,0xFF,0x55,0xFF,0xAA,0xFF,0x55,0xFF,0xAA,0xFF
.byte 0xAA,0xFF,0xAA,0xFF,0xAA,0xFF,0x95,0xFF,0x52,0xFF,0xA9,0xFF,0x4A,0xFF,0xA8,0xFF
.byte 0xAA,0xFF,0x95,0xFF,0x52,0xFF,0x4A,0xFF,0xA9,0xFF,0x25,0xFF,0x94,0xFF,0x4A,0xFF
.byte 0xAA,0xFF,0x55,0xFF,0xAA,0xFF,0x55,0xFF,0x4A,0xFF,0x29,0xFF,0xA4,0xFF,0x52,0xFF
.byte 0xA4,0xFF,0x2A,0xFF,0xA1,0xFF,0x55,0xFF,0x48,0xFF,0x25,0xFF,0x94,0xFF,0x4A,0xFF
.byte 0x8E,0xD3,0x3F,0xC1,0x37,0xC8,0x2B,0xD4,0xBD,0xC2,0x0A,0xF5,0xBB,0xC4,0x25,0xDA
.byte 0x42,0xE8,0x73,0x88,0xFF,0x00,0xE7,0x10,0xAD,0x52,0xDD,0x22,0x9F,0x60,0x5F,0xA0
.byte 0xA0,0x00,0x54,0x06,0xF0,0x06,0xFB,0x08,0xB7,0x48,0xFE,0x01,0xE7,0x10,0xFF,0x00
.byte 0x00,0x0F,0xF6,0x13,0x9A,0x03,0xFC,0x03,0xFE,0x21,0xFF,0x00,0xDF,0x40,0xFF,0x40
.byte 0x09,0xFF,0x88,0xF7,0x28,0xE7,0x8C,0xF3,0x1E,0xC3,0xDE,0x21,0xD5,0x2A,0xFB,0x04
.byte 0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x20,0xDF,0x20,0xBF,0x00,0x7F
.byte 0x40,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF
.byte 0x0D,0xFF,0x0E,0xFF,0x06,0xFF,0x06,0xFF,0x07,0xFF,0x06,0xFF,0x03,0xFF,0x03,0xFF
.byte 0x00,0xFF,0x00,0xFF,0x80,0xFF,0x00,0xFF,0x00,0xFF,0x80,0xFF,0x40,0xFF,0x20,0xFF
.byte 0x00,0xFF,0x00,0xFF,0x80,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF
; Line 0x18
.byte 0xAA,0xFF,0x55,0xFF,0x92,0xFF,0x49,0xFF,0xAA,0xFF,0x55,0xFF,0x92,0xFF,0x49,0xFF
.byte 0x54,0xFF,0x4A,0xFF,0xA9,0xFF,0x55,0xFF,0x22,0xFF,0x54,0xFF,0x4A,0xFF,0x20,0xFF
.byte 0x95,0xFF,0x4A,0xFF,0x51,0xFF,0x2A,0xFF,0x85,0xFF,0x50,0xFF,0x8A,0xFF,0x51,0xFF
.byte 0x25,0xFF,0xA8,0xFF,0x45,0xFF,0x28,0xFF,0x45,0xFF,0x20,0xFF,0x94,0xFF,0x02,0xFF
.byte 0x15,0xFF,0xA0,0xFF,0x15,0xFF,0xA0,0xFF,0x15,0xFF,0x80,0xFF,0x54,0xFF,0x01,0xFF
.byte 0x21,0xFF,0x94,0xFF,0x42,0xFF,0x28,0xFF,0x02,0xFF,0xA8,0xFF,0x02,0xFF,0x27,0xFF
.byte 0x7D,0xC2,0x28,0xD7,0xB5,0xCA,0x70,0xCF,0x24,0xDF,0xC0,0xFF,0x20,0xFF,0x80,0xFF
.byte 0x1F,0xE0,0xAE,0x51,0xAF,0xD0,0x32,0xDF,0x02,0xFF,0x00,0xFF,0x08,0xF7,0x95,0x6A
.byte 0xDF,0x20,0x87,0x68,0x57,0xA8,0xCC,0xF7,0x0A,0xF5,0x4A,0xF5,0x07,0xF8,0xB3,0x6C
.byte 0xDF,0x20,0x7E,0x81,0x5F,0xA0,0xBC,0x42,0x87,0x78,0xA0,0x5D,0xF9,0x06,0xFE,0x01
.byte 0xB6,0x48,0x7C,0x03,0x73,0x8C,0xE1,0x1A,0xE5,0x12,0x8B,0x64,0x07,0xC8,0x95,0x6A
.byte 0x80,0x7F,0x80,0x7F,0x60,0x9F,0x40,0xBF,0xB0,0x4F,0xD2,0x2D,0x74,0x83,0xF4,0x2B
.byte 0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF
.byte 0x01,0xFF,0x01,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF
.byte 0x90,0xFF,0xD0,0xFF,0xA4,0xFB,0xDA,0xF5,0xEC,0xFB,0x74,0xFB,0x69,0xFE,0x30,0xFF
.byte 0x80,0xFF,0xC0,0xBF,0xC0,0xBF,0x80,0xFF,0x80,0xFF,0x80,0xFF,0x80,0xFF,0x80,0xFF
; Line 0x20
.byte 0xA4,0xFF,0x12,0xFF,0xA9,0xFF,0x44,0xFF,0x22,0xFF,0x91,0xFF,0x48,0xFF,0x04,0xFF
.byte 0x95,0xFF,0x40,0xFF,0x2A,0xFF,0x81,0xFF,0x28,0xFF,0x05,0xFF,0xA0,0xFF,0x09,0xFF
.byte 0x08,0xFF,0xA5,0xFF,0x10,0xFF,0x44,0xFF,0x11,0xFF,0x44,0xFF,0x11,0xFF,0x04,0xFF
.byte 0x51,0xFF,0x08,0xFF,0xA2,0xFF,0x08,0xFF,0x22,0xFF,0x08,0xFF,0x41,0xFF,0x08,0xFF
.byte 0x54,0xFF,0x01,0xFF,0x49,0xFF,0x02,0xFF,0xA4,0xFF,0x0A,0xFF,0x18,0xFF